{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ef679261",
   "metadata": {},
   "source": [
    "________________\n",
    "* 2022/10/17/week09\n",
    "* Python学习记录\n",
    "________________"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "276256da",
   "metadata": {},
   "source": [
    "# 本周知识点\n",
    "\n",
    "* 1. 用户输入\n",
    "* 2. 文本的格式化输出"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2a91c18c",
   "metadata": {},
   "source": [
    "## 1.用户输入\n",
    "\n",
    "* input方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "b2b223a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xuanyi\n",
      "1111\n"
     ]
    }
   ],
   "source": [
    "# 用户登录系统\n",
    "username = input()\n",
    "password = input()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "30ef7a3c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "xuanyi\n",
      "1111\n"
     ]
    }
   ],
   "source": [
    "print(username)\n",
    "print(password)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c51bbb7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账号: shjgcbde\n",
      "密码: shcdgi\n",
      "账号不存在或密码不正确！请重新输入！\n"
     ]
    }
   ],
   "source": [
    "# 用户登录系统 迭代1\n",
    "user01 = \"xuanyi\"\n",
    "password01 = \"1111\"\n",
    "\n",
    "username = input(\"账号: \")\n",
    "password = input(\"密码: \")\n",
    "# 情景1：账号密码都正确\n",
    "\n",
    "if user01 == username and password01 == password:\n",
    "    print(\"登陆成功~欢迎\"+user01)\n",
    "    \n",
    "\n",
    "# 情景2：账号不存在或密码不正确\n",
    "else:\n",
    "    print(\"账号不存在或密码不正确！请重新输入！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e7a5bf44",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账号: xuanyi\n",
      "密码: 1111\n",
      "登陆成功~欢迎xuanyi\n"
     ]
    }
   ],
   "source": [
    "# 用户登录系统 迭代1\n",
    "user01 = \"xuanyi\"\n",
    "password01 = \"1111\"\n",
    "\n",
    "username = input(\"账号: \")\n",
    "password = input(\"密码: \")\n",
    "# 情景1：账号密码都正确\n",
    "\n",
    "if user01 == username and password01 == password:\n",
    "    print(\"登陆成功~欢迎\"+user01)\n",
    "    \n",
    "\n",
    "# 情景2：账号不存在或密码不正确\n",
    "else:\n",
    "    print(\"账号不存在或密码不正确！请重新输入！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "331f3d24",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "账号：admin\n",
      "密码：123456\n",
      "登陆成功~欢迎admin\n"
     ]
    }
   ],
   "source": [
    "# 用户登录系统 迭代2 循环！ 5分钟，加油~for + range() \n",
    "\n",
    "user01 = \"admin\"\n",
    "password01 = \"123456\"\n",
    "\n",
    "for i in range(3,0,-1):\n",
    "    username = input(\"账号：\")\n",
    "    password = input(\"密码：\")\n",
    "    # 情景一：账号密码都正确\n",
    "    if user01 == username and password01 == password:\n",
    "        print(\"登陆成功~欢迎\"+user01)\n",
    "        break # 终止循环\n",
    "        \n",
    "        \n",
    "    # 情景二：帐号不存在或密码不正确，用户可以输入三次，三次之后1小时之后再来尝试\n",
    "    else:\n",
    "        if i>1:\n",
    "            print(\"账号不存在或密码不正确！请重新输入！您还有\"+str(i-1)+\"次尝试的机会\")\n",
    "        else:\n",
    "            print(\"账号不存在或密码不正确！请1小时后再来尝试\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2ff1e405",
   "metadata": {},
   "source": [
    "## 2.字符串的格式化输出\n",
    "\n",
    "> 1. 字符串的拼接\n",
    "> 2. 占位符\n",
    "> 3. 格式化输出的方法：format()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "fe49ddb8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "昵称: 阿旭\n",
      "地区: 深圳\n",
      "工作: 产品经理助理\n",
      "年龄: 22\n",
      "期待薪资: 10K/月\n"
     ]
    }
   ],
   "source": [
    "# 用户的信息输入(完善信息) ：字符串的拼接\n",
    "name = input(\"昵称: \")\n",
    "region = input(\"地区: \")\n",
    "job = input(\"工作: \")\n",
    "age = input(\"年龄: \")\n",
    "salary = input(\"期待薪资: \")\n",
    "\n",
    "info = '''----------INFO'''+ name +'''----------\n",
    "地区:'''+ region +'''\n",
    "工作:'''+ job +'''\n",
    "年龄:'''+ age +'''\n",
    "薪资期待:'''+ salary\n",
    "# 好麻烦，好容易出错！"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2606ce0e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "----------INFO阿旭----------\n",
      "地区:深圳\n",
      "工作:产品经理助理\n",
      "年龄:22\n",
      "薪资期待:10K/月\n"
     ]
    }
   ],
   "source": [
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a5d174b6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "昵称: 阿旭\n",
      "地区: 广州\n",
      "工作: 数据分析师\n",
      "年龄: 22\n",
      "期待薪资: 15K/月\n"
     ]
    },
    {
     "ename": "ValueError",
     "evalue": "unsupported format character '?' (0xa) at index 28",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [6]\u001b[0m, in \u001b[0;36m<cell line: 8>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      5\u001b[0m age \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m年龄: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m      6\u001b[0m salary \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m期待薪资: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m----> 8\u001b[0m info \u001b[38;5;241m=\u001b[39m \u001b[38;5;124;43m'''\u001b[39;49m\u001b[38;5;124;43m----------INFO s\u001b[39;49m\u001b[38;5;124;43m%\u001b[39;49m\u001b[38;5;124;43m ----------\u001b[39;49m\n\u001b[0;32m      9\u001b[0m \u001b[38;5;124;43m地区: s\u001b[39;49m\u001b[38;5;124;43m%\u001b[39;49m\n\u001b[0;32m     10\u001b[0m \u001b[38;5;124;43m工作: s\u001b[39;49m\u001b[38;5;124;43m%\u001b[39;49m\n\u001b[0;32m     11\u001b[0m \u001b[38;5;124;43m年龄: s\u001b[39;49m\u001b[38;5;124;43m%\u001b[39;49m\n\u001b[0;32m     12\u001b[0m \u001b[38;5;124;43m薪资期待: s\u001b[39;49m\u001b[38;5;124;43m%\u001b[39;49m\u001b[38;5;124;43m \u001b[39;49m\u001b[38;5;124;43m'''\u001b[39;49m\u001b[38;5;241;43m%\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43mregion\u001b[49m\u001b[43m,\u001b[49m\u001b[43mjob\u001b[49m\u001b[43m,\u001b[49m\u001b[43mage\u001b[49m\u001b[43m,\u001b[49m\u001b[43msalary\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m     13\u001b[0m \u001b[38;5;28mprint\u001b[39m(info)\n",
      "\u001b[1;31mValueError\u001b[0m: unsupported format character '?' (0xa) at index 28"
     ]
    }
   ],
   "source": [
    "# 用户的信息输入(完善信息) : 占位符 s%\n",
    "name = input(\"昵称: \")\n",
    "region = input(\"地区: \")\n",
    "job = input(\"工作: \")\n",
    "age = input(\"年龄: \")\n",
    "salary = input(\"期待薪资: \")\n",
    "\n",
    "info = '''----------INFO s% ----------\n",
    "地区: s%\n",
    "工作: s%\n",
    "年龄: s%\n",
    "薪资期待: s% '''%(name,region,job,age,salary)\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "fe57c4c1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "昵称: 阿旭\n",
      "地区: 深圳\n",
      "工作: 前端开发\n",
      "年龄: 22\n",
      "期待薪资: 11K/月\n",
      "----------INFO 阿旭 ----------\n",
      "地区: 深圳\n",
      "工作: 前端开发\n",
      "年龄: 22\n",
      "薪资期待: 11K/月 \n"
     ]
    }
   ],
   "source": [
    "# 用户的信息输入(完善信息) : 占位符 %s\n",
    "name = input(\"昵称: \")\n",
    "region = input(\"地区: \")\n",
    "job = input(\"工作: \")\n",
    "age = input(\"年龄: \")\n",
    "salary = input(\"期待薪资: \")\n",
    "\n",
    "info = '''----------INFO %s ----------\n",
    "地区: %s\n",
    "工作: %s\n",
    "年龄: %s\n",
    "薪资期待: %s '''%(name,region,job,age,salary)\n",
    "print(info)\n",
    "# 局限性：有序，个数确定，不能乱写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c9e0883e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "昵称: 阿旭\n",
      "地区: 深圳\n",
      "工作: python web开发\n",
      "年龄: 22\n",
      "期待薪资: 18K/月\n"
     ]
    },
    {
     "ename": "KeyError",
     "evalue": "'工作的职位'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "Input \u001b[1;32mIn [18]\u001b[0m, in \u001b[0;36m<cell line: 8>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      5\u001b[0m age \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m年龄: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m      6\u001b[0m salary \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m期待薪资: \u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m----> 8\u001b[0m info \u001b[38;5;241m=\u001b[39m \u001b[38;5;124;43m'''\u001b[39;49m\u001b[38;5;124;43m -------INFO\u001b[39;49m\u001b[38;5;132;43;01m{昵称}\u001b[39;49;00m\u001b[38;5;124;43m------- \u001b[39;49m\n\u001b[0;32m      9\u001b[0m \u001b[38;5;124;43m地区: \u001b[39;49m\u001b[38;5;132;43;01m{地区}\u001b[39;49;00m\n\u001b[0;32m     10\u001b[0m \u001b[38;5;124;43m工作: \u001b[39;49m\u001b[38;5;132;43;01m{工作的职位}\u001b[39;49;00m\n\u001b[0;32m     11\u001b[0m \u001b[38;5;124;43m年龄: \u001b[39;49m\u001b[38;5;132;43;01m{年龄}\u001b[39;49;00m\n\u001b[0;32m     12\u001b[0m \u001b[38;5;124;43m薪资期待: \u001b[39;49m\u001b[38;5;132;43;01m{薪资}\u001b[39;49;00m\u001b[38;5;124;43m \u001b[39;49m\u001b[38;5;124;43m'''\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mformat\u001b[49m\u001b[43m(\u001b[49m\u001b[43m工作职位\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mjob\u001b[49m\u001b[43m,\u001b[49m\u001b[43m薪资\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msalary\u001b[49m\u001b[43m,\u001b[49m\u001b[43m昵称\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m年龄\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mage\u001b[49m\u001b[43m,\u001b[49m\u001b[43m地区\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mregion\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m     13\u001b[0m \u001b[38;5;28mprint\u001b[39m(info)\n",
      "\u001b[1;31mKeyError\u001b[0m: '工作的职位'"
     ]
    }
   ],
   "source": [
    "# 用户的信息输入(完善信息) : format()    #不考虑顺序，只考虑一一对应的关系。\n",
    "name = input(\"昵称: \")\n",
    "region = input(\"地区: \")\n",
    "job = input(\"工作: \")\n",
    "age = input(\"年龄: \")\n",
    "salary = input(\"期待薪资: \")\n",
    "\n",
    "info = ''' -------INFO{昵称}------- \n",
    "地区: {地区}\n",
    "工作: {工作的职位}\n",
    "年龄: {年龄}\n",
    "薪资期待: {薪资} '''.format(工作职位=job,薪资=salary,昵称=name,年龄=age,地区=region)\n",
    "print(info)\n",
    "# "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "946796c2",
   "metadata": {},
   "source": [
    "## 课后作业：\n",
    "> 1. 第二章P93 前所有项目练习（下周讲）\n",
    "> 2. 购物车项目\n",
    ">> 要求：\n",
    ">> 1. 运行程序后，让用户输入支付宝余额，然后打印我们的商品列表给用户，\n",
    ">> 2. 让用户输入商品编号进行商品的购买，\n",
    ">> 3. 用户选择商品后，检查用户的余额是否够，若够则直接扣款，不够则提醒用户，\n",
    ">> 4. 用户可以随时退出购买，退出时打印用户已购买的商品和支付宝余额。\n",
    "\n",
    "* 温馨提示：网上有很多购物车项目(但由于很多人为了\"炫技\"，99%以上我们可能读不懂)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "00a15b0f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "欢迎使用711便利店自助点餐服务\n",
      "请输入您的支付宝余额（数字）：100\n",
      "输入q退出点餐服务并支付\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：0,1,3,4\n",
      "请输入商品编号：\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：0\n",
      "您已经将商品魔芋丝添加到了购物车，您的支付宝余额是98.2\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：1\n",
      "您已经将商品萝卜添加到了购物车，您的支付宝余额是95.9\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：2\n",
      "您已经将商品紫菜豆腐包添加到了购物车，您的支付宝余额是93.60000000000001\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：3\n",
      "您已经将商品海带丝结添加到了购物车，您的支付宝余额是91.80000000000001\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：3\n",
      "您已经将商品海带丝结添加到了购物车，您的支付宝余额是90.00000000000001\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：3\n",
      "您已经将商品海带丝结添加到了购物车，您的支付宝余额是88.20000000000002\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：3\n",
      "您已经将商品海带丝结添加到了购物车，您的支付宝余额是86.40000000000002\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：3\n",
      "您已经将商品海带丝结添加到了购物车，您的支付宝余额是84.60000000000002\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：55\n",
      "您选择的商品不在商品列表内\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：2\n",
      "您已经将商品紫菜豆腐包添加到了购物车，您的支付宝余额是82.30000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：12\n",
      "您已经将商品蟹籽福袋添加到了购物车，您的支付宝余额是78.80000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：12\n",
      "您已经将商品蟹籽福袋添加到了购物车，您的支付宝余额是75.30000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：12\n",
      "您已经将商品蟹籽福袋添加到了购物车，您的支付宝余额是71.80000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：12\n",
      "您已经将商品蟹籽福袋添加到了购物车，您的支付宝余额是68.30000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：12\n",
      "您已经将商品蟹籽福袋添加到了购物车，您的支付宝余额是64.80000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是60.40000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是56.00000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是51.60000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是47.20000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是42.80000000000003\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是38.400000000000034\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是34.000000000000036\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是29.600000000000037\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是25.20000000000004\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是20.80000000000004\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是16.40000000000004\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是12.00000000000004\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是7.6000000000000405\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：10\n",
      "您已经将商品牛筋丸串添加到了购物车，您的支付宝余额是3.20000000000004\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入商品编号：10\n",
      "您的支付宝余额不足，请选择其他商品\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：0\n",
      "您已经将商品魔芋丝添加到了购物车，您的支付宝余额是1.40000000000004\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：0\n",
      "您的支付宝余额不足，请选择其他商品\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：F\n",
      "请输入商品编号：\n",
      "0 ('魔芋丝', 1.8)\n",
      "1 ('萝卜', 2.3)\n",
      "2 ('紫菜豆腐包', 2.3)\n",
      "3 ('海带丝结', 1.8)\n",
      "4 ('风琴串', 2.9)\n",
      "5 ('香菇串', 2.9)\n",
      "6 ('芝士章鱼丸子烧串', 3.9)\n",
      "7 ('白玉子串', 2.9)\n",
      "8 ('黄金脆骨棒', 3.4)\n",
      "9 ('香菇鸡肉棒棒串', 3.9)\n",
      "10 ('牛筋丸串', 4.4)\n",
      "11 ('脆骨北极翅', 3.9)\n",
      "12 ('蟹籽福袋', 3.5)\n",
      "请输入商品编号：q\n",
      "----------购物车清单----------\n",
      "('魔芋丝', 1.8)\n",
      "('萝卜', 2.3)\n",
      "('紫菜豆腐包', 2.3)\n",
      "('海带丝结', 1.8)\n",
      "('海带丝结', 1.8)\n",
      "('海带丝结', 1.8)\n",
      "('海带丝结', 1.8)\n",
      "('海带丝结', 1.8)\n",
      "('紫菜豆腐包', 2.3)\n",
      "('蟹籽福袋', 3.5)\n",
      "('蟹籽福袋', 3.5)\n",
      "('蟹籽福袋', 3.5)\n",
      "('蟹籽福袋', 3.5)\n",
      "('蟹籽福袋', 3.5)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('牛筋丸串', 4.4)\n",
      "('魔芋丝', 1.8)\n",
      "您的支付宝余额是1.40000000000004\n"
     ]
    }
   ],
   "source": [
    "# 购物车——711便利店关东煮\n",
    "\n",
    "product_list = [('魔芋丝', 1.8),\n",
    "                ('萝卜', 2.3),\n",
    "                ('紫菜豆腐包', 2.3),\n",
    "                ('海带丝结', 1.8),\n",
    "                ('风琴串', 2.9),\n",
    "                ('香菇串', 2.9),\n",
    "                ('芝士章鱼丸子烧串', 3.9),\n",
    "                ('白玉子串', 2.9),\n",
    "                ('黄金脆骨棒', 3.4),\n",
    "                ('香菇鸡肉棒棒串', 3.9),\n",
    "                ('牛筋丸串', 4.4),\n",
    "                ('脆骨北极翅', 3.9),\n",
    "                ('蟹籽福袋', 3.5)]\n",
    "shopping_car = []\n",
    "print(\"欢迎使用711便利店自助点餐服务\")\n",
    "zhifubao = input(\"请输入您的支付宝余额（数字）：\")\n",
    "print(\"输入q退出点餐服务并支付\")\n",
    "if zhifubao.isdigit():\n",
    "    zhifubao = int(zhifubao)\n",
    "    while True:\n",
    "        for item in product_list:\n",
    "            print(product_list.index(item),item)\n",
    "        choice = input(\"请输入商品编号：\")\n",
    "        if choice.isdigit():\n",
    "            choice = int(choice)\n",
    "            if choice >= 0 and choice <= 13:\n",
    "                if zhifubao >= product_list[choice][1]:\n",
    "                    zhifubao = zhifubao - product_list[choice][1]\n",
    "                    shopping_car.append(product_list[choice])\n",
    "                    print(\"您已经将商品%s添加到了购物车，您的支付宝余额是%s\" % (product_list[choice][0],zhifubao))\n",
    "                else:\n",
    "                    print(\"您的支付宝余额不足，请选择其他商品\")\n",
    "            else:\n",
    "                print(\"您选择的商品不在商品列表内\")\n",
    "        elif choice==\"q\":\n",
    "            print(\"----------购物车清单----------\")\n",
    "            for item in shopping_car:\n",
    "                print(item)\n",
    "            print(\"您的支付宝余额是%s\" % zhifubao)\n",
    "            break\n",
    "        else:\n",
    "            print(\"请输入商品编号：\")\n",
    "else:\n",
    "    print(\"请输入您的支付宝余额（数字）：\")\n",
    "                \n",
    "                \n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b0a6d25e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "63570668",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
